package com.mdc.mansion.api.web.modules.basedata;

import java.util.Calendar;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;
import com.mdc.mansion.api.web.common.web.BaseController;
import com.mdc.mansion.common.response.Result;
import com.mdc.mansion.common.response.ResultCode;
import com.mdc.mansion.core.common.util.RestaurantSupport;
import com.mdc.mansion.core.modules.basedata.FeedbackMsgService;
import com.mdc.mansion.dataaccess.modules.basedata.entity.FeedbackMsg;

@Controller
@RequestMapping(value = "${adminPath}/feedback")
public class FeedbackMsgController extends BaseController {
	
    @Autowired
    private FeedbackMsgService feedbackMsgService;
    
    @RequestMapping("save")
    public Result save(String data){
    	   Result result=new Result(ResultCode.COMMON_SUCCESS);
    	   JSONObject parameterObj = JSONObject.parseObject(data);
    	   if(!(parameterObj.containsKey("msgMemuId") || parameterObj.containsKey("msgInfo") || parameterObj.containsKey("contactInfo")))
    	   {
    		   result.setCode(ResultCode.COMMON_EXCEPTION);
    		   return result;
    	   }
    	   
    	   FeedbackMsg feedbackMsg = new FeedbackMsg();
    	   /**版本号**/
    	   feedbackMsg.setVersion(parameterObj.getString("version"));
    	   /**意见类型ID**/
    	   feedbackMsg.setMsgMemuId(parameterObj.getString("msgMemuId"));
    	   /**意见内容**/
    	   feedbackMsg.setMsgInfo(parameterObj.getString("msgInfo"));
    	   /**联系方式**/
    	   feedbackMsg.setContactInfo(parameterObj.getString("contactInfo"));
    	   
    	   feedbackMsg.setCreateBy(RestaurantSupport.getCurrentOperationUser());
    	   feedbackMsg.setCreateTime(Calendar.getInstance().getTime());
    	   feedbackMsgService.save(feedbackMsg);
           return result;
    }

}
